package jscinttools.scint.statbox;

import jscinttools.scint.*;

import jscinttools.utilities.jhplotutilities.*;
import jscinttools.utilities.aidautilities.*;

import hep.aida.*;

import java.lang.String;
import java.text.DecimalFormat;

import jhplot.jadraw.JaText;

/**
 *  Description of the Class
 *
 *@author     marc-antoine
 *@created    3 avril 2011
 */
public class StatBoxSpec extends StatBoxJa implements FigureParametersJHPlot
{
	private Spectrum spectrum = null;


	/**
	 *  Constructor for the StatBoxJa object
	 *
	 *@param  spectrum  Description of the Parameter
	 */
	public StatBoxSpec(Spectrum spectrum)
	{
		this.spectrum = spectrum;
		IFitResult fitRes = spectrum.getFitRes();

		DecimalFormat fmt = new DecimalFormat("#.###");

		String[] statLine = new String[4];
		statLine[0] = "Amp = " + fmt.format(fitRes.fittedParameters()[0]) + " &plusmn; " + fmt.format(fitRes.errors()[0]);
		statLine[1] = "&micro; = " + fmt.format(fitRes.fittedParameters()[1]) + " &plusmn; " + fmt.format(fitRes.errors()[1]);
		statLine[2] = "&sigma; = " + fmt.format(fitRes.fittedParameters()[2]) + " &plusmn; " + fmt.format(fitRes.errors()[2]);
		statLine[3] = "&Chi;^{2} = " + fmt.format(fitRes.quality());

		this.statBox = new JaText[statLine.length];
		for (int i = 0; i < statLine.length; i++)
		{
			statBox[i] = new JaText(statLine[i], 0.17, 0.25 + (i * 0.035), "NDC");
			statBox[i].setFont(statBoxFont);
			statBox[i].setColor(colors[0]);
		}
	}
}

